using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Commerce.Common
{
	/// <summary>
	/// Strongly-typed collection for the Category class.
	/// </summary>
	[Serializable]
	public partial class CategoryCollection : ActiveList<Category,CategoryCollection> 
	{	   
		public CategoryCollection() {}

        /// <summary>
        /// Filters an existing collection based on the set criteria. This is an in-memory filter
        /// Thanks to developingchris for this!
        /// </summary>
        /// <returns>CategoryCollection</returns>
		public CategoryCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                Category o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        switch (w.Comparison)
                        {
                            case SubSonic.Comparison.Equals:
                                if (!val.Equals(w.ParameterValue))
                                {
                                    remove = true;
                                }
                                break;
                        }
                    }
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }


    }

	/// <summary>
	/// This is an ActiveRecord class which wraps the CSK_Store_Category table.
	/// </summary>
	[Serializable]
	public partial class Category : ActiveRecord<Category>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public Category()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public Category(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

        
		public Category(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public Category(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }

		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("CSK_Store_Category", TableType.Table, DataService.GetInstance("dashCommerce"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarCategoryID = new TableSchema.TableColumn(schema);
				colvarCategoryID.ColumnName = "categoryID";
				colvarCategoryID.DataType = DbType.Int32;
				colvarCategoryID.MaxLength = 0;
				colvarCategoryID.AutoIncrement = false;
				colvarCategoryID.IsNullable = false;
				colvarCategoryID.IsPrimaryKey = true;
				colvarCategoryID.IsForeignKey = false;
				colvarCategoryID.IsReadOnly = false;
				colvarCategoryID.DefaultSetting = @"";
				colvarCategoryID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCategoryID);
				
				TableSchema.TableColumn colvarCategoryGUID = new TableSchema.TableColumn(schema);
				colvarCategoryGUID.ColumnName = "categoryGUID";
				colvarCategoryGUID.DataType = DbType.Guid;
				colvarCategoryGUID.MaxLength = 0;
				colvarCategoryGUID.AutoIncrement = false;
				colvarCategoryGUID.IsNullable = false;
				colvarCategoryGUID.IsPrimaryKey = false;
				colvarCategoryGUID.IsForeignKey = false;
				colvarCategoryGUID.IsReadOnly = false;
				
				colvarCategoryGUID.DefaultSetting = @"(newid())";
				colvarCategoryGUID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCategoryGUID);
				
				TableSchema.TableColumn colvarCategoryName = new TableSchema.TableColumn(schema);
				colvarCategoryName.ColumnName = "categoryName";
				colvarCategoryName.DataType = DbType.String;
				colvarCategoryName.MaxLength = 150;
				colvarCategoryName.AutoIncrement = false;
				colvarCategoryName.IsNullable = false;
				colvarCategoryName.IsPrimaryKey = false;
				colvarCategoryName.IsForeignKey = false;
				colvarCategoryName.IsReadOnly = false;
				colvarCategoryName.DefaultSetting = @"";
				colvarCategoryName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCategoryName);

                // 2/7/2008 - PVS added
                TableSchema.TableColumn colvarManufacturerID = new TableSchema.TableColumn(schema);
                colvarManufacturerID.ColumnName = "manufacturerID";
                colvarManufacturerID.DataType = DbType.Int32;
                colvarManufacturerID.MaxLength = 0;
                colvarManufacturerID.AutoIncrement = false;
                colvarManufacturerID.IsNullable = true;
                colvarManufacturerID.IsPrimaryKey = false;
                colvarManufacturerID.IsForeignKey = false;
                colvarManufacturerID.IsReadOnly = false;

                colvarManufacturerID.DefaultSetting = @"((0))";
                colvarManufacturerID.ForeignKeyTableName = "";
                schema.Columns.Add(colvarManufacturerID);
				
				TableSchema.TableColumn colvarImageFile = new TableSchema.TableColumn(schema);
				colvarImageFile.ColumnName = "imageFile";
				colvarImageFile.DataType = DbType.String;
				colvarImageFile.MaxLength = 500;
				colvarImageFile.AutoIncrement = false;
				colvarImageFile.IsNullable = true;
				colvarImageFile.IsPrimaryKey = false;
				colvarImageFile.IsForeignKey = false;
				colvarImageFile.IsReadOnly = false;
				colvarImageFile.DefaultSetting = @"";
				colvarImageFile.ForeignKeyTableName = "";
				schema.Columns.Add(colvarImageFile);
				
				TableSchema.TableColumn colvarParentID = new TableSchema.TableColumn(schema);
				colvarParentID.ColumnName = "parentID";
				colvarParentID.DataType = DbType.Int32;
				colvarParentID.MaxLength = 0;
				colvarParentID.AutoIncrement = false;
				colvarParentID.IsNullable = true;
				colvarParentID.IsPrimaryKey = false;
				colvarParentID.IsForeignKey = false;
				colvarParentID.IsReadOnly = false;
				
						colvarParentID.DefaultSetting = @"((0))";
				colvarParentID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarParentID);
				
				TableSchema.TableColumn colvarShortDescription = new TableSchema.TableColumn(schema);
				colvarShortDescription.ColumnName = "shortDescription";
				colvarShortDescription.DataType = DbType.String;
				colvarShortDescription.MaxLength = 500;
				colvarShortDescription.AutoIncrement = false;
				colvarShortDescription.IsNullable = true;
				colvarShortDescription.IsPrimaryKey = false;
				colvarShortDescription.IsForeignKey = false;
				colvarShortDescription.IsReadOnly = false;
				colvarShortDescription.DefaultSetting = @"";
				colvarShortDescription.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShortDescription);
				
				TableSchema.TableColumn colvarLongDescription = new TableSchema.TableColumn(schema);
				colvarLongDescription.ColumnName = "longDescription";
				colvarLongDescription.DataType = DbType.String;
				colvarLongDescription.MaxLength = 1073741823;
				colvarLongDescription.AutoIncrement = false;
				colvarLongDescription.IsNullable = true;
				colvarLongDescription.IsPrimaryKey = false;
				colvarLongDescription.IsForeignKey = false;
				colvarLongDescription.IsReadOnly = false;
				colvarLongDescription.DefaultSetting = @"";
				colvarLongDescription.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLongDescription);
				
				TableSchema.TableColumn colvarListOrder = new TableSchema.TableColumn(schema);
				colvarListOrder.ColumnName = "listOrder";
				colvarListOrder.DataType = DbType.Int32;
				colvarListOrder.MaxLength = 0;
				colvarListOrder.AutoIncrement = false;
				colvarListOrder.IsNullable = false;
				colvarListOrder.IsPrimaryKey = false;
				colvarListOrder.IsForeignKey = false;
				colvarListOrder.IsReadOnly = false;
				
						colvarListOrder.DefaultSetting = @"((1))";
				colvarListOrder.ForeignKeyTableName = "";
				schema.Columns.Add(colvarListOrder);
				
				TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
				colvarCreatedOn.ColumnName = "createdOn";
				colvarCreatedOn.DataType = DbType.DateTime;
				colvarCreatedOn.MaxLength = 0;
				colvarCreatedOn.AutoIncrement = false;
				colvarCreatedOn.IsNullable = true;
				colvarCreatedOn.IsPrimaryKey = false;
				colvarCreatedOn.IsForeignKey = false;
				colvarCreatedOn.IsReadOnly = false;
				
						colvarCreatedOn.DefaultSetting = @"(getdate())";
				colvarCreatedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedOn);
				
				TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
				colvarCreatedBy.ColumnName = "createdBy";
				colvarCreatedBy.DataType = DbType.String;
				colvarCreatedBy.MaxLength = 50;
				colvarCreatedBy.AutoIncrement = false;
				colvarCreatedBy.IsNullable = true;
				colvarCreatedBy.IsPrimaryKey = false;
				colvarCreatedBy.IsForeignKey = false;
				colvarCreatedBy.IsReadOnly = false;
				colvarCreatedBy.DefaultSetting = @"";
				colvarCreatedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedBy);
				
				TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
				colvarModifiedOn.ColumnName = "modifiedOn";
				colvarModifiedOn.DataType = DbType.DateTime;
				colvarModifiedOn.MaxLength = 0;
				colvarModifiedOn.AutoIncrement = false;
				colvarModifiedOn.IsNullable = true;
				colvarModifiedOn.IsPrimaryKey = false;
				colvarModifiedOn.IsForeignKey = false;
				colvarModifiedOn.IsReadOnly = false;
				
						colvarModifiedOn.DefaultSetting = @"(getdate())";
				colvarModifiedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedOn);
				
				TableSchema.TableColumn colvarModifiedBy = new TableSchema.TableColumn(schema);
				colvarModifiedBy.ColumnName = "modifiedBy";
				colvarModifiedBy.DataType = DbType.String;
				colvarModifiedBy.MaxLength = 50;
				colvarModifiedBy.AutoIncrement = false;
				colvarModifiedBy.IsNullable = true;
				colvarModifiedBy.IsPrimaryKey = false;
				colvarModifiedBy.IsForeignKey = false;
				colvarModifiedBy.IsReadOnly = false;
				colvarModifiedBy.DefaultSetting = @"";
				colvarModifiedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedBy);
				
				TableSchema.TableColumn colvarStatusID = new TableSchema.TableColumn(schema);
				colvarStatusID.ColumnName = "statusID";
				colvarStatusID.DataType = DbType.Int32;
				colvarStatusID.MaxLength = 0;
				colvarStatusID.AutoIncrement = false;
				colvarStatusID.IsNullable = true;
				colvarStatusID.IsPrimaryKey = false;
				colvarStatusID.IsForeignKey = false;
				colvarStatusID.IsReadOnly = false;
				colvarStatusID.DefaultSetting = @"";
				colvarStatusID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarStatusID);
				
				TableSchema.TableColumn colvarUrlFriendly = new TableSchema.TableColumn(schema);
				colvarUrlFriendly.ColumnName = "urlFriendly";
				colvarUrlFriendly.DataType = DbType.String;
				colvarUrlFriendly.MaxLength = 150;
				colvarUrlFriendly.AutoIncrement = false;
				colvarUrlFriendly.IsNullable = false;
				colvarUrlFriendly.IsPrimaryKey = false;
				colvarUrlFriendly.IsForeignKey = false;
				colvarUrlFriendly.IsReadOnly = false;
				
						colvarUrlFriendly.DefaultSetting = @"('')";
				colvarUrlFriendly.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUrlFriendly);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["dashCommerce"].AddSchema("CSK_Store_Category",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("CategoryID")]
		public int CategoryID 
		{
			get { return GetColumnValue<int>(Columns.CategoryID); }

			set { SetColumnValue(Columns.CategoryID, value); }

		}

		  
		[XmlAttribute("CategoryGUID")]
		public Guid CategoryGUID 
		{
			get { return GetColumnValue<Guid>(Columns.CategoryGUID); }

			set { SetColumnValue(Columns.CategoryGUID, value); }

		}

		  
		[XmlAttribute("CategoryName")]
		public string CategoryName 
		{
			get { return GetColumnValue<string>(Columns.CategoryName); }

			set { SetColumnValue(Columns.CategoryName, value); }
		}
		  

		  
		[XmlAttribute("ImageFile")]
		public string ImageFile 
		{
			get { return GetColumnValue<string>(Columns.ImageFile); }

			set { SetColumnValue(Columns.ImageFile, value); }

		}

		
		
		//private int? propParentID;
		[XmlAttribute("ParentID")]
		public int ParentID 
		{
			get
			{
			int? propParentID = GetColumnValue<int?>(Columns.ParentID);
				if (!propParentID.HasValue)
					return 0;
				return propParentID.Value;
			}

		   set { SetColumnValue(Columns.ParentID, value); }

		}

		
		[XmlIgnore]
		public bool ParentIDHasValue
		{
            get { return GetColumnValue<int?>("parentID") != null; }

			set
			{
				int? propParentID = GetColumnValue<int?>(Columns.ParentID);
				if (!value)
					SetColumnValue(Columns.ParentID, null);
				else if (value && !propParentID.HasValue)
					SetColumnValue(Columns.ParentID, 0);
		   }

		}

		
		  
		[XmlAttribute("ShortDescription")]
		public string ShortDescription 
		{
			get { return GetColumnValue<string>(Columns.ShortDescription); }

			set { SetColumnValue(Columns.ShortDescription, value); }

		}

		  
		[XmlAttribute("LongDescription")]
		public string LongDescription 
		{
			get { return GetColumnValue<string>(Columns.LongDescription); }

			set { SetColumnValue(Columns.LongDescription, value); }

		}

		  
		[XmlAttribute("ListOrder")]
		public int ListOrder 
		{
			get { return GetColumnValue<int>(Columns.ListOrder); }

			set { SetColumnValue(Columns.ListOrder, value); }

		}

		
		
		//private DateTime? propCreatedOn;
		[XmlAttribute("CreatedOn")]
		public DateTime CreatedOn 
		{
			get
			{
			DateTime? propCreatedOn = GetColumnValue<DateTime?>(Columns.CreatedOn);
				if (!propCreatedOn.HasValue)
					return new DateTime(1900,01, 01);
				return propCreatedOn.Value;
			}

		   set { SetColumnValue(Columns.CreatedOn, value); }

		}

		
		[XmlIgnore]
		public bool CreatedOnHasValue
		{
			get { return GetColumnValue<DateTime?>("createdOn") != null; }

			set
			{
				DateTime? propCreatedOn = GetColumnValue<DateTime?>(Columns.CreatedOn);
				if (!value)
					SetColumnValue(Columns.CreatedOn, null);
				else if (value && !propCreatedOn.HasValue)
					SetColumnValue(Columns.CreatedOn, new DateTime(1900,01, 01));
		   }

		}

		
		  
		[XmlAttribute("CreatedBy")]
		public string CreatedBy 
		{
			get { return GetColumnValue<string>(Columns.CreatedBy); }

			set { SetColumnValue(Columns.CreatedBy, value); }

		}

		
		
		//private DateTime? propModifiedOn;
		[XmlAttribute("ModifiedOn")]
		public DateTime ModifiedOn 
		{
			get
			{
			DateTime? propModifiedOn = GetColumnValue<DateTime?>(Columns.ModifiedOn);
				if (!propModifiedOn.HasValue)
					return new DateTime(1900,01, 01);
				return propModifiedOn.Value;
			}

		   set { SetColumnValue(Columns.ModifiedOn, value); }

		}

		
		[XmlIgnore]
		public bool ModifiedOnHasValue
		{
			get { return GetColumnValue<DateTime?>("modifiedOn") != null; }

			set
			{
				DateTime? propModifiedOn = GetColumnValue<DateTime?>(Columns.ModifiedOn);
				if (!value)
					SetColumnValue(Columns.ModifiedOn, null);
				else if (value && !propModifiedOn.HasValue)
					SetColumnValue(Columns.ModifiedOn, new DateTime(1900,01, 01));
		   }

		}

		
		  
		[XmlAttribute("ModifiedBy")]
		public string ModifiedBy 
		{
			get { return GetColumnValue<string>(Columns.ModifiedBy); }

			set { SetColumnValue(Columns.ModifiedBy, value); }

		}
		  
		[XmlAttribute("UrlFriendly")]
		[Bindable(true)]
		public string UrlFriendly 
		{
			get { return GetColumnValue<string>(Columns.UrlFriendly); }
			set { SetColumnValue(Columns.UrlFriendly, value); }
		}
		
		#endregion
		
		
		#region PrimaryKey Methods
		
        protected override void SetPrimaryKey(object oValue)
        {
            base.SetPrimaryKey(oValue);
            
            SetPKValues();
        }
        
		
		public Commerce.Common.ProductCategoryMapCollection ProductCategoryMapRecords()
		{
			return new Commerce.Common.ProductCategoryMapCollection().Where(ProductCategoryMap.Columns.CategoryID, CategoryID).Load();
		}

		#endregion
		
			
		
		//no foreign key tables defined (0)
		
		
		
		#region Many To Many Helpers
		
		 
		public Commerce.Common.ProductCollection GetProductCollection() { return Category.GetProductCollection(this.CategoryID).OrderByAsc("listOrder"); }

		public static Commerce.Common.ProductCollection GetProductCollection(int varCategoryID)
		{
            SubSonic.QueryCommand cmd = new SubSonic.QueryCommand("SELECT * FROM [dbo].[CSK_Store_Product] INNER JOIN [CSK_Store_Product_Category_Map] ON [CSK_Store_Product].[productID] = [CSK_Store_Product_Category_Map].[productID] WHERE [CSK_Store_Product].[isDeleted] = 0 AND [CSK_Store_Product_Category_Map].[categoryID] = @categoryID", Category.Schema.Provider.Name);
			cmd.AddParameter("@categoryID", varCategoryID, DbType.Int32);
			IDataReader rdr = SubSonic.DataService.GetReader(cmd);
			ProductCollection coll = new ProductCollection();
			coll.LoadAndCloseReader(rdr);
			return coll;
		}

		
		public static void SaveProductMap(int varCategoryID, ProductCollection items)
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			QueryCommand cmdDel = new QueryCommand("DELETE FROM [CSK_Store_Product_Category_Map] WHERE [CSK_Store_Product_Category_Map].[categoryID] = @categoryID", Category.Schema.Provider.Name);
			cmdDel.AddParameter("@categoryID", varCategoryID, DbType.Int32);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (Product item in items)
			{
				ProductCategoryMap varProductCategoryMap = new ProductCategoryMap();
				varProductCategoryMap.SetColumnValue("categoryID", varCategoryID);
				varProductCategoryMap.SetColumnValue("productID", item.GetPrimaryKeyValue());
				varProductCategoryMap.Save();
			}

		}

		public static void SaveProductMap(int varCategoryID, System.Web.UI.WebControls.ListItemCollection itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM [CSK_Store_Product_Category_Map] WHERE [CSK_Store_Product_Category_Map].[categoryID] = @categoryID", Category.Schema.Provider.Name);
			cmdDel.AddParameter("@categoryID", varCategoryID, DbType.Int32);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (System.Web.UI.WebControls.ListItem l in itemList) 
			{
				if (l.Selected) 
				{
					ProductCategoryMap varProductCategoryMap = new ProductCategoryMap();
					varProductCategoryMap.SetColumnValue("categoryID", varCategoryID);
					varProductCategoryMap.SetColumnValue("productID", l.Value);
					varProductCategoryMap.Save();
				}

			}

		}

		public static void SaveProductMap(int varCategoryID , int[] itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM [CSK_Store_Product_Category_Map] WHERE [CSK_Store_Product_Category_Map].[categoryID] = @categoryID", Category.Schema.Provider.Name);
			cmdDel.AddParameter("@categoryID", varCategoryID, DbType.Int32);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (int item in itemList) 
			{
				ProductCategoryMap varProductCategoryMap = new ProductCategoryMap();
				varProductCategoryMap.SetColumnValue("categoryID", varCategoryID);
				varProductCategoryMap.SetColumnValue("productID", item);
				varProductCategoryMap.Save();
			}

		}

		
		public static void DeleteProductMap(int varCategoryID) 
		{
			QueryCommand cmdDel = new QueryCommand("DELETE FROM [CSK_Store_Product_Category_Map] WHERE [CSK_Store_Product_Category_Map].[categoryID] = @categoryID", Category.Schema.Provider.Name);
			cmdDel.AddParameter("@categoryID", varCategoryID, DbType.Int32);
			DataService.ExecuteQuery(cmdDel);
		}

		
		#endregion
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(int varCategoryID,Guid varCategoryGUID,string varCategoryName,string varImageFile,int varParentID,string varShortDescription,string varLongDescription,int varListOrder,DateTime varCreatedOn,string varCreatedBy,DateTime varModifiedOn,string varModifiedBy,int? varStatusID,string varUrlFriendly)
		{
			Category item = new Category();
			
			item.CategoryID = varCategoryID;
			
			item.CategoryGUID = varCategoryGUID;
			
			item.CategoryName = varCategoryName;

			
			item.ImageFile = varImageFile;
			
			item.ParentID = varParentID;
			
			item.ShortDescription = varShortDescription;
			
			item.LongDescription = varLongDescription;
			
			item.ListOrder = varListOrder;
			
			item.CreatedOn = varCreatedOn;
			
			item.CreatedBy = varCreatedBy;
			
			item.ModifiedOn = varModifiedOn;
			
			item.ModifiedBy = varModifiedBy;
			
			
			item.UrlFriendly = varUrlFriendly;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varCategoryID,Guid varCategoryGUID,string varCategoryName,string varImageFile,int varParentID,string varShortDescription,string varLongDescription,int varListOrder,DateTime varCreatedOn,string varCreatedBy,DateTime varModifiedOn,string varModifiedBy,int? varStatusID,string varUrlFriendly)
		{
			Category item = new Category();
			
				item.CategoryID = varCategoryID;
			
				item.CategoryGUID = varCategoryGUID;
			
				item.CategoryName = varCategoryName;
			
				item.ImageFile = varImageFile;
			
				item.ParentID = varParentID;
			
				item.ShortDescription = varShortDescription;
			
				item.LongDescription = varLongDescription;
			
				item.ListOrder = varListOrder;
			
				item.CreatedOn = varCreatedOn;
			
				item.CreatedBy = varCreatedBy;
			
				item.ModifiedOn = varModifiedOn;
			
				item.ModifiedBy = varModifiedBy;

			
				item.UrlFriendly = varUrlFriendly;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn CategoryIDColumn
        {
            get { return Schema.Columns[0]; }

        }

        
        
        
        public static TableSchema.TableColumn CategoryGUIDColumn
        {
            get { return Schema.Columns[1]; }

        }

        
        
        
        public static TableSchema.TableColumn CategoryNameColumn
        {
            get { return Schema.Columns[2]; }

        }

        
        
        
        public static TableSchema.TableColumn ImageFileColumn
        {
            get { return Schema.Columns[3]; }

        }

        
        
        
        public static TableSchema.TableColumn ParentIDColumn
        {
            get { return Schema.Columns[4]; }

        }

        
        
        
        public static TableSchema.TableColumn ShortDescriptionColumn
        {
            get { return Schema.Columns[5]; }

        }

        
        
        
        public static TableSchema.TableColumn LongDescriptionColumn
        {
            get { return Schema.Columns[6]; }

        }

        
        
        
        public static TableSchema.TableColumn ListOrderColumn
        {
            get { return Schema.Columns[7]; }

        }

        
        
        
        public static TableSchema.TableColumn CreatedOnColumn
        {
            get { return Schema.Columns[8]; }

        }

        
        
        
        public static TableSchema.TableColumn CreatedByColumn
        {
            get { return Schema.Columns[9]; }

        }

        
        
        
        public static TableSchema.TableColumn ModifiedOnColumn
        {
            get { return Schema.Columns[10]; }

        }

        
        
        
        public static TableSchema.TableColumn ModifiedByColumn
        {
            get { return Schema.Columns[11]; }

        }
        
        
        
        public static TableSchema.TableColumn StatusIDColumn
        {
            get { return Schema.Columns[12]; }
        }
        
        
        
        public static TableSchema.TableColumn UrlFriendlyColumn
        {
            get { return Schema.Columns[13]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string CategoryID = @"categoryID";
			 public static string CategoryGUID = @"categoryGUID";
			 public static string CategoryName = @"categoryName";
			 public static string ImageFile = @"imageFile";
			 public static string ParentID = @"parentID";
			 public static string ShortDescription = @"shortDescription";
			 public static string LongDescription = @"longDescription";
			 public static string ListOrder = @"listOrder";
			 public static string CreatedOn = @"createdOn";
			 public static string CreatedBy = @"createdBy";
			 public static string ModifiedOn = @"modifiedOn";
			 public static string ModifiedBy = @"modifiedBy";
			 public static string StatusID = @"statusID";
			 public static string UrlFriendly = @"urlFriendly";
						
		}

		#endregion
		
		#region Update PK Collections
		
        public void SetPKValues()
        {
}
        #endregion
    
        #region Deep Save
		
        public void DeepSave()
        {
            Save();
            
}
        #endregion
	}
}

